function main(){
    const sum = +readline();
    const obj = {};
    for(let i = 0;i<sum;i++){
        const [index,value] = readline().split(' ');

        if(obj[index]){
            obj[index] += value;
        }else{
            obj[index] = value;
        }
    }

    for(let item in obj){
        console.log(`${item} ${obj[item]}`)
    }
}

main()